/**
 * 
 */
package com.tcc.task;

/**
 * @company CampusCruiser
 * @author Emily_Wang
 * @date 2012-5-28
 */

import org.apache.xpath.operations.String;
import org.openqa.selenium.By;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import com.tcc.qa.test.util.BaseTest;
import com.tcc.qa.test.util.DatePicker;
import com.tcc.qa.test.util.FileDataSource;
import com.tcc.qa.test.util.InputFinder;
import com.tcc.qa.test.util.SelectFinder;
import com.tcc.qa.test.util.SwitchTo;

	public class DataProvide extends BaseTest{
		

		@Test(dataProvider="dp")
		public void newTask(String title, String category, String priority, String year, String month, String day, String status, String notes){
			getWebDriver().get(super.getTestDomainURL()+"q?cx=u&pg=papp&tg=Tasks-editTask");
			InputFinder.getInputById(getWebDriver(), "mainForm", "title").sendKeys(title);
			SelectFinder.getSelectById(getWebDriver(), "category").selectByVisibleText(category);
		    SelectFinder.getSelectById(getWebDriver(), "priority").selectByVisibleText(priority);
		    DatePicker.getDatePicker(getWebDriver());
		    SwitchTo.switchToIframe(getWebDriver(), "datePicker");
		    InputFinder.getInputByName(getWebDriver(), "year").sendKeys(year);
		    SelectFinder.getSelectByName(getWebDriver(), "month").getOptions().get(Integer.valueOf(month)-1).click();
		    getWebDriver().findElement(By.linkText(day)).click();
		    SwitchTo.switchToDefault(getWebDriver());
		    SelectFinder.getSelectById(getWebDriver(), "statusId").selectByVisibleText(status);
				getWebDriver().findElement(By.id("ccEditorrtfDetail")).sendKeys(notes);
			getWebDriver().findElement(By.xpath("//input[@value='Save']")).click();
			
		}
		@DataProvider
		public Object[][] dp(){
			 return FileDataSource.getDatas(DataProvide.class, "tasks.xml");
		}
	}

